<template>
    <!--ASN明细-->
    <div id="AsnDetails">
        <v-details :detailData="data.detailData" :inputConfig="inputConfig" :rules="rules"></v-details>
    </div>
</template>

<script>

    import details from 'commons/Detail'
    import baseMixin from "@/mixins/BaseMixin";

    export default {
        name: "",
        mixins: [baseMixin],
        props: {
            data: {
                type: Object
            }
        },
        data() {
            return {
                addflag: false
            }
        },
        computed: {
            rules() {
                if (this.data.type == "Department_list") {
                    return {
                        dept_code: [
                            {required: true, trigger: 'blur'},
                        ]
                    }
                } else if (this.data.type == "Interface_list") {
                    return {
                        interface_code: [
                            {required: true, trigger: 'blur'},
                        ],
                        interface_desc: [
                            {required: true, trigger: 'blur'},
                        ]
                    }
                }
            },
            inputConfig() {
                if (this.data.type == "Department_list") {
                    return [
                        [
                            {
                                type: "input",
                                label: this.$t("config.depart"),
                                props: "dept_code",
                                disabled: this.addflag
                            },
                            {
                                type: "input",
                                label: this.$t('common.desc'),
                                props: "dept_name",
                            }
                        ],
                    ]
                } else if (this.data.type == "Interface_list") {
                    return [
                        [
                            {
                                type: "input",
                                label: "界面代码",
                                props: "interface_code",
                                disabled: this.addflag
                            },
                            {
                                type: "input",
                                label: this.$t('common.desc'),
                                props: "interface_desc",
                                disabled: this.addflag
                            },
                            {
                                type: "input",
                                label: "程序名称",
                                props: "program_name",
                            },
                            {
                                type: "input",
                                label: "程序位置",
                                props: "file_location",
                            }
                        ],
                    ]
                }
            }
        },
        methods: {},
        mounted() {
            if (!this.$store.state.newFlag && !this.$parent.detailsNew) {
                this.addflag = true;
            } else {
                this.addflag = false;
            }
        },
        watch: {},
        components: {
            'v-details': details
        }
    }
</script>

<style scoped>

</style>
